package com.ruoyi.app.controller;

import com.ruoyi.app.model.vo.ModifyUserInfoReq;
import com.ruoyi.app.model.vo.ModifyUserPhoneReq;
import com.ruoyi.app.model.vo.ModifyUserPwdReq;
import com.ruoyi.app.model.vo.ModifyUserRealNameReq;
import com.ruoyi.app.service.UserService;
import com.ruoyi.common.core.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author 侯存路
 * @description
 * @since 2020/10/22 16:09
 */
@Api(value = "用户相关", tags = "用户相关接口")
@RestController
@RequestMapping("/api/user")
@Slf4j
public class UserController {


    @Autowired
    private UserService userService;


    @ApiOperation("获取用户详情")
    @GetMapping("/get-user-info")
    public AjaxResult getUserInfo() {
        return AjaxResult.success(userService.getUserInfo());
    }


    @ApiOperation("修改用户信息")
    @PostMapping("/modify-user-info")
    public AjaxResult modifyUserInfo(@RequestBody ModifyUserInfoReq req) {
        return AjaxResult.success(userService.modifyUserInfo(req));
    }


    @ApiOperation("修改密码")
    @PostMapping("/modify-user-pwd")
    public AjaxResult modifyUserPwd(@RequestBody ModifyUserPwdReq req) {
        return AjaxResult.success(userService.modifyUserPwd(req));
    }


    @ApiOperation("修改手机号")
    @PostMapping("/modify-user-phone")
    public AjaxResult modifyUserPhone(@RequestBody @Validated ModifyUserPhoneReq req) {
        return AjaxResult.success(userService.modifyUserPhone(req));
    }


    @ApiOperation("签到")
    @GetMapping("/sign-in")
    public AjaxResult signIn() {
        return AjaxResult.success(userService.signIn());
    }


    @ApiOperation("连续签到几天/任务列表")
    @PostMapping("taskList")
    public AjaxResult taskList() {
        return AjaxResult.success(userService.taskList());
    }


    @ApiOperation("实名认证")
    @PostMapping("/modify-user-auth")
    public AjaxResult modifyUserAuth(@RequestBody @Validated ModifyUserRealNameReq req) {
        return AjaxResult.success(userService.modifyUserAuth(req));
    }


    @ApiOperation("今日是否签到 true 已签  false 未签")
    @GetMapping("/sign-today")
    public AjaxResult signToday() {
        return AjaxResult.success(userService.signToday());
    }

}
